#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 110;
int L, m;
struct S
{
    int l, r;
}s[N];

bool cmp(S a, S b)
{
    if (a.l != b.l) {
        return a.l < b.l;
    }
    else {
        return a.r < b.r;
    }
}
int main()
{
    cin >> L >> m;
    for (int i = 0; i < m; i++) {
        cin >> s[i].l >> s[i].r;
    }
    sort(s, s + m, cmp);
    int ans = 0;
    int st = 0;
    int ed = -1;
    for (int i = 0; i < m; i++) {
        int l = s[i].l;
        int r = s[i].r;
        if (ed < l) {
            ans += ed - st + 1;
            st = l;
            ed = r;
        }
        else {
            ed = max(ed, r);
        }
    }
    ans += ed - st + 1;
    cout << L + 1 - ans << endl;
    return 0;
}